var pic_lis = document.getElementById("b_pic").getElementsByTagName("li");

var an_lis = document.getElementById("b_an").getElementsByTagName("li");

an_lis[0].style.background = "#b31114";

var c = 0;

function h_slide() {
  c++;

  if (c == pic_lis.length) {
    c = 0;
  }

  for (var i = 0; i < pic_lis.length; i++) {
    pic_lis[i].style.display = "none";

    an_lis[i].style.background = "#86939b";
  }

  pic_lis[c].style.display = "block";

  an_lis[c].style.background = "#b31114";
}

var timer = setInterval(h_slide, 5000);

for (var j = 0; j < pic_lis.length; j++) {
  an_lis[j].index = j;

  an_lis[j].onmouseover = function () {
    index = this.index;

    clearInterval(timer);

    for (var k = 0; k < an_lis.length; k++) {
      pic_lis[k].style.display = "none";

      an_lis[k].style.background = "#86939b";
    }

    pic_lis[index].style.display = "block";

    an_lis[index].style.background = "#b31114";
  };

  an_lis[j].onmouseout = function () {
    timer = setInterval(h_slide, 5000);
  };
}
var pic_lis = document.getElementById("b_pic").getElementsByTagName("li");

var an_lis = document.getElementById("b_an").getElementsByTagName("li");

an_lis[0].style.background = "#b31114";

var c = 0;

function h_slide() {
  c++;

  if (c == pic_lis.length) {
    c = 0;
  }

  for (var i = 0; i < pic_lis.length; i++) {
    pic_lis[i].style.display = "none";

    an_lis[i].style.background = "#86939b";
  }

  pic_lis[c].style.display = "block";

  an_lis[c].style.background = "#b31114";
}

var timer = setInterval(h_slide, 5000);

for (var j = 0; j < pic_lis.length; j++) {
  an_lis[j].index = j;

  an_lis[j].onmouseover = function () {
    index = this.index;

    clearInterval(timer);

    for (var k = 0; k < an_lis.length; k++) {
      pic_lis[k].style.display = "none";

      an_lis[k].style.background = "#86939b";
    }

    pic_lis[index].style.display = "block";

    an_lis[index].style.background = "#b31114";
  };

  an_lis[j].onmouseout = function () {
    timer = setInterval(h_slide, 5000);
  };
}
var pic_lis = document.getElementById("b_pic").getElementsByTagName("li");

var an_lis = document.getElementById("b_an").getElementsByTagName("li");

an_lis[0].style.background = "#b31114";

var c = 0;

function h_slide() {
  c++;

  if (c == pic_lis.length) {
    c = 0;
  }

  for (var i = 0; i < pic_lis.length; i++) {
    pic_lis[i].style.display = "none";

    an_lis[i].style.background = "#86939b";
  }

  pic_lis[c].style.display = "block";

  an_lis[c].style.background = "#b31114";
}

var timer = setInterval(h_slide, 5000);

for (var j = 0; j < pic_lis.length; j++) {
  an_lis[j].index = j;

  an_lis[j].onmouseover = function () {
    index = this.index;

    clearInterval(timer);

    for (var k = 0; k < an_lis.length; k++) {
      pic_lis[k].style.display = "none";

      an_lis[k].style.background = "#86939b";
    }

    pic_lis[index].style.display = "block";

    an_lis[index].style.background = "#b31114";
  };

  an_lis[j].onmouseout = function () {
    timer = setInterval(h_slide, 5000);
  };
}
var pic_lis = document.getElementById("b_pic").getElementsByTagName("li");

var an_lis = document.getElementById("b_an").getElementsByTagName("li");

an_lis[0].style.background = "#b31114";

var c = 0;

function h_slide() {
  c++;

  if (c == pic_lis.length) {
    c = 0;
  }

  for (var i = 0; i < pic_lis.length; i++) {
    pic_lis[i].style.display = "none";

    an_lis[i].style.background = "#86939b";
  }

  pic_lis[c].style.display = "block";

  an_lis[c].style.background = "#b31114";
}

var timer = setInterval(h_slide, 5000);

for (var j = 0; j < pic_lis.length; j++) {
  an_lis[j].index = j;

  an_lis[j].onmouseover = function () {
    index = this.index;

    clearInterval(timer);

    for (var k = 0; k < an_lis.length; k++) {
      pic_lis[k].style.display = "none";

      an_lis[k].style.background = "#86939b";
    }

    pic_lis[index].style.display = "block";

    an_lis[index].style.background = "#b31114";
  };

  an_lis[j].onmouseout = function () {
    timer = setInterval(h_slide, 5000);
  };
}

function verifyName(){
	var username = document.querySelector('[name=username]')
	username.addEventListener('change',verifyName)
	var span = username.nextElementSibling
	var reg = /^[a-zA-Z0-9-_]{6,10}$/
	if(!reg.test(username.value)){
		span.innerText='输入不合法，请输入6~10位'
		return false
	}
	span.innerText=''
	return true
}
verifyName();






function verifyPassword(){
	var password = document.querySelector('[name=password]')
	password.addEventListener('change',verifyPassword)
	var span = password.nextElementSibling
	var reg = /^[a-zA-Z0-9-_]{6,20}$/
	if(!reg.test(password.value)){
		span.innerText='输入不合法，请输入由6~20位数字、字母和符号组成的密码'
		return false
	}
	span.innerText=''
	return true
}
verifyPassword();

function verifyConfirm(){
	var confirm = document.querySelector('[name=confirm]')
	confirm.addEventListener('change',verifyConfirm)
	var span = confirm.nextElementSibling
	if(confirm.value !== password.value){
		span.innerText='两次密码输入不一致'
		return false
	}
	span.innerText=''
	return true
}
verifyConfirm();
function verifyButton(){
	var form = document.querySelector('form')
	form.addEventListener('submit',function(e){
		if(!verifyName()) e.preventDefault()
		if(!verifyPassword()) e.preventDefault()
		if(!verifyConfirm()) e.preventDefault()
	})
}
verifyButton();